package br.com.verde.exemploteca.functions

object FunctionsV2 {
  // Improvemnts with Higher-order Functions
  
  def sum(f: Int => Int, a: Int, b: Int): Int =
    if (a > b) 0 else f(a) + sum(f, a + 1, b)
  
  def sumInts(a: Int, b: Int): Int = sum(id, a, b)
  
  def sumSquares(a: Int, b: Int): Int = sum(square, a, b)
  
  def id(x: Int): Int = x
  
  def square(x: Int): Int = x * x
  
  def main(args : Array[String]) : Unit = {}
}
